import os
# 正样本的路径
path = r'E:\pycharmWorkspace\trainTest\mask\has_mask'
filelist = os.listdir(path)
# 开始文件名1000.jpg
count = 1000
for file in filelist:
    Olddir = os.path.join(path, file)
    if os.path.isdir(Olddir):
        continue
    filename = os.path.splitext(file)[0]
    filetype = os.path.splitext(file)[1]
    Newdir = os.path.join(path, str(count) + filetype)
    os.rename(Olddir, Newdir)
    count += 1

# 负样本的路径
path = r'E:\pycharmWorkspace\trainTest\mask\no_mask'
filelist = os.listdir(path)
# 开始文件名10000.jpg
count = 10000
for file in filelist:
    Olddir = os.path.join(path, file)
    if os.path.isdir(Olddir):
        continue
    filename = os.path.splitext(file)[0]
    filetype = os.path.splitext(file)[1]
    Newdir = os.path.join(path, str(count) + filetype)
    os.rename(Olddir, Newdir)
    count += 1


